home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3c / flock.z / flock
Encoding:
Text File  |  2002-10-03  |  5.3 KB  |  133 lines

  1.  
  2.  
  3.  
  4. FFFFLLLLOOOOCCCCKKKK((((3333BBBB))))                                                            FFFFLLLLOOOOCCCCKKKK((((3333BBBB))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      flock - apply or remove an advisory lock on an open file
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ffffiiiilllleeee....hhhh>>>>
  13.  
  14.      iiiinnnntttt fffflllloooocccckkkk((((iiiinnnntttt ffffdddd,,,, iiiinnnntttt ooooppppeeeerrrraaaattttiiiioooonnnn))));;;;
  15.  
  16. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.      _F_l_o_c_k applies or removes an _a_d_v_i_s_o_r_y lock on the file associated with the
  18.      file descriptor _f_d.  A lock is applied by specifying one of the following
  19.      as an _o_p_e_r_a_t_i_o_n parameter:  LLLLOOOOCCCCKKKK____SSSSHHHH, LLLLOOOOCCCCKKKK____EEEEXXXX, LLLLOOOOCCCCKKKK____SSSSHHHH||||LLLLOOOOCCCCKKKK____NNNNBBBB or
  20.      LLLLOOOOCCCCKKKK____EEEEXXXX||||LLLLOOOOCCCCKKKK____NNNNBBBB.  Note that LLLLOOOOCCCCKKKK____NNNNBBBB, if used, must appear in an inclusive
  21.      OR expression with either LLLLOOOOCCCCKKKK____SSSSHHHH or LLLLOOOOCCCCKKKK____EEEEXXXX.  To unlock an existing
  22.      lock, _o_p_e_r_a_t_i_o_n should be LLLLOOOOCCCCKKKK____UUUUNNNN.
  23.  
  24.      Advisory locks allow cooperating processes to perform consistent
  25.      operations on files, but do not guarantee consistency (i.e., processes
  26.      may still access files without using advisory locks, possibly resulting
  27.      in inconsistencies).
  28.  
  29.      The locking mechanism allows two types of locks:  _s_h_a_r_e_d locks and
  30.      _e_x_c_l_u_s_i_v_e locks.  At any time multiple shared locks may be applied to a
  31.      file, but at no time are multiple exclusive, or both shared and
  32.      exclusive, locks allowed simultaneously on a file.
  33.  
  34.      A shared lock may be _u_p_g_r_a_d_e_d to an exclusive lock, and vice versa,
  35.      simply by specifying the appropriate lock type; this results in the
  36.      previous lock being released and the new lock applied (possibly after
  37.      other processes have gained and released the lock).
  38.  
  39.      Requesting a lock on an object that is already locked normally causes the
  40.      caller to be blocked until the lock may be acquired.  If LLLLOOOOCCCCKKKK____NNNNBBBB is
  41.      included in _o_p_e_r_a_t_i_o_n, then this will not happen; instead the call will
  42.      fail and the error EEEEWWWWOOOOUUUULLLLDDDDBBBBLLLLOOOOCCCCKKKK will be returned.
  43.  
  44. NNNNOOOOTTTTEEEESSSS
  45.      Locks are on files, not file descriptors.  That is, file descriptors
  46.      duplicated through _d_u_p(3C) (but not through _f_o_r_k(2), see the BUGS section
  47.      below) do not result in multiple instances of a lock, but rather multiple
  48.      references to a single lock.  Thus if any of the descriptors associated
  49.      with the same file are closed, the lock associated with the file is lost.
  50.  
  51.      Processes blocked awaiting a lock may be awakened by signals.
  52.  
  53.      In C++, the function name _f_l_o_c_k collides with the structure name _f_l_o_c_k
  54.      (which is declared in <_s_y_s/_f_c_n_t_l._h> and included in <_s_y_s/_f_i_l_e._h> ).  When
  55.      using _f_l_o_c_k() in C++, one must define ____BBBBSSSSDDDD____CCCCOOOOMMMMPPPPAAAATTTT before including
  56.      _s_y_s/_f_i_l_e._h
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FFFFLLLLOOOOCCCCKKKK((((3333BBBB))))                                                            FFFFLLLLOOOOCCCCKKKK((((3333BBBB))))
  71.  
  72.  
  73.  
  74. RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
  75.      Zero is returned if the operation was successful; on an error a -1 is
  76.      returned and an error code is left in the global location _e_r_r_n_o.
  77.  
  78. EEEERRRRRRRROOOORRRRSSSS
  79.      The _f_l_o_c_k call fails if:
  80.  
  81.      [EWOULDBLOCK]       The file is locked and the LLLLOOOOCCCCKKKK____NNNNBBBB option was
  82.                          specified.
  83.  
  84.      [EBADF]             The argument _f_d is an invalid descriptor.
  85.  
  86.      [EINVAL]            The argument _f_d refers to an object other than a
  87.                          file.
  88.  
  89. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  90.      open(2), close(2), dup(3C), execve(2), fcntl(2), fork(2), lockf(3)
  91.  
  92. BBBBUUUUGGGGSSSS
  93.      Unlike BSD, child processes created by _f_o_r_k(2) do not inherit references
  94.      to locks acquired by their parents through _f_l_o_c_k(3B) calls.  This bug
  95.      results from _f_l_o_c_k's implementation atop System V file and record locks.
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.